package com.jyx.file.io.bank;

import java.util.Scanner;

public class Atm {
	double number;
	String name;
	String pin;
	int open;
	Atm() {
		number = 0;
		name = null;
		pin = null;
		open = 0;
	}
	void Registration() {
		if (open == 1) {
			System.out.println("已存在账户！");
			return;
		}
		Scanner reader = new Scanner(System.in);
		System.out.print("请输入用户名：");
		name = reader.nextLine();
		System.out.print("请输入密码：");
		pin = reader.nextLine();
		System.out.print("请输入初始存款金额：");
		number = reader.nextDouble();
		System.out.println("注册并存款成功");
		open = 1;
	}
	int Login() {
		if (open == 0) {
			System.out.println("没有已存在账户");
			return 0;
		}
		String cname;
		String cpin;
		Scanner rd = new Scanner(System.in);
		System.out.print("请输入用户名：");
		cname = rd.nextLine();
		System.out.print("请输入密码：");
		cpin = rd.nextLine();
		if ((name.equals(cname)) && (pin.equals(cpin))) {
			System.out.println("登录成功！");
			return 1;
		} else {
			System.out.println("登录失败");
			return 0;
		}

	}
	void innumber(String iname, String ipin, double inumber) {
		name = iname;
		pin = ipin;
		number = inumber;
		if (name != null) {
			open = 1;
		}
	}
	void Balance() {
		System.out.println("余额为：" + number);
	}
	void GetMoney() {
		Scanner reader = new Scanner(System.in);
		double num = 0;
		System.out.print("请输入取款金额：");
		num = reader.nextDouble();
		if (num > number) {
			System.out.println("您的余额不足！");
		} else {
			number = number - num;
			System.out.println("取款成功！");
			Balance();
		}
	}
	void PutMoney() {
		Scanner reader = new Scanner(System.in);
		double num = 0;
		System.out.print("请输入存款金额：");
		num = reader.nextDouble();
		number += num;
		System.out.print("存款成功");
		Balance();
	}
	String RN() {
		return name;
	}
	String RP() {
		return pin;
	}
	double RNu() {
		return number;
	}
	void outnumber() {
		System.out.println("余额:" + number);
	}
}
